<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/templates/template.xhtml">
	<ui:define name="pageTitle">Construtora</ui:define>
	<ui:define name="pageHeader">Listagem de Construtoras</ui:define>
	<ui:define name="body">
		<h:panelGrid columns="1">
			<!--  
			<p:commandButton value="Nova Construtora" type="button"
				onclick="dialogGerConstrutora.show(); return false;" />
		-->

		</h:panelGrid>
		<h:form>
			<p:dataTable id="dtGestor" editable="true" paginator="true"
				value="#{gestorBean.lista}" var="gestor" rows="5"
				style="font-size:12px;margin-top:10px"
				emptyMessage="Nenhum cadastro efetuado! ">

				<f:facet name="header">
					<h:outputText value="Lista de Gestores" />
				</f:facet>
				<p:column headerText="Gestor" style="font-size:12px;">
										#{gestor.nome}
									</p:column>

				<p:column headerText="Nível" style="font-size:12px;">
										#{gestor.perfilUsuario.tipo}
									</p:column>
				<p:column headerText="Construtora" style="font-size:12px;">
										#{gestor.construtora.razaoSocial}
				</p:column>
				<p:column style="width:2%">

					<h:commandLink action="#{gestorBean.excluir()}"
						onclick="if(!confirm('Deseja realmente excluir o Gestor #{configUsuario.gestor.nome}?')) return false;">
						<div align="center">
							<h:graphicImage url="/templates/Imagens/delete-2.png" />
						</div>
						<f:setPropertyActionListener
							target="#{gestorBean.gestorSelecionado}" value="#{gestor}" />
					</h:commandLink>
					<h:outputText value=" " />
				</p:column>
				<p:column style="width:2%">
					<h:commandLink>
						<h:graphicImage url="/templates/Imagens/icon_pencil.png" />
						<f:setPropertyActionListener
							target="#{gestorBean.gestorSelecionado}" value="#{gestor}" />

					</h:commandLink>
				</p:column>
			</p:dataTable>
		</h:form>
		<p />
		<h:form>
			<h:inputHidden value="#{gestorBean.gestorSelecionado.id}" />
			<p:fieldset legend="Gestor(es):" toggleable="false"
				style="width:90%;font-size:12px;">
				<h:panelGrid id="pnGestor" style="float: left;width:100%">
					<p:row>
						<p:column>
							<h:outputLabel id="lblConstrutora" value="Construtora:"
								style="float: left;width:25%;margin-right:20px; font-weight: bold;font-size:12px;" />
						</p:column>

					</p:row>
					<p:row>
						<p:column>
							<p:selectOneMenu id="slmConstrutora"
								style="float: left;width:100%; font-weight: bold;font-size:12px;font-size:12px;"
								value="#{gestorBean.construtoraSelecionada}">
								<f:selectItems value="#{gestorBean.construtoraSelect}" />
							</p:selectOneMenu>
						</p:column>
					</p:row>
					<p:row>
						<p:column>
							<h:outputLabel id="lblNivel" value="Nível:" for="Nivel"
								style="float: left;width:25%; font-weight: bold;font-size:12px;font-size:12px;" />
						</p:column>
					</p:row>
					<p:row>
						<p:column>

							<p:selectOneMenu id="slmNivel"
								style="float: left;width:100%; font-weight: bold;font-size:12px;font-size:12px;"
								value="#{gestorBean.perfilSelecionado}">
								<f:selectItems value="#{gestorBean.perfilSelect}" />
							</p:selectOneMenu>
						</p:column>

					</p:row>
					<p:row>
						<p:column>
							<h:outputLabel id="lblGestor" value="Gestor:" for="Gestor"
								style="float: left;width:60%;margin-right:20px; font-weight: bold;font-size:12px;" />
						</p:column>

					</p:row>
					<p:row>
						<p:column>
							<h:inputText id="txtGestor" converter="toUpperCaseConverter"
								value="#{gestorBean.gestorSelecionado.nome}"
								style="width:60%;" required="true" requiredMessage=" *">
								<f:ajax event="blur" render="@this" />
							</h:inputText>
							<h:message for="txtGestor" errorClass="errorMessage"
										style="font-weight: bold;font-size:18px;color:red" />
						</p:column>

						<p:column>
							<h:commandButton value="Salvar Usuário" style="margin-left:20px;"
								action="#{gestorBean.salvar()}" />
						</p:column>
					</p:row>
					<p:row>
						<p:column>
							<h:outputLabel id="lblUsuario" value="Usuário:"
								style="float: left;width:25%;margin-right:5px; font-weight: bold;font-size:12px;" />
						</p:column>
						<p:column>
							<h:outputLabel id="lblSenha" value="Senha:"
								style="float: left;width:25%; font-weight: bold;font-size:12px;font-size:12px;margin-left:65px" />
						</p:column>
					</p:row>
					<p:row>
						<p:column>
							<h:inputText id="txtLogin" style="width:25%;"
								converter="toUpperCaseConverter"
								value="#{gestorBean.gestorSelecionado.login}" required="true"
								requiredMessage=" *">
								<f:ajax event="blur" render="@this" />
							</h:inputText>
							<h:message for="txtLogin" errorClass="errorMessage"
										style="font-weight: bold;font-size:18px;color:red" />
						</p:column>
						<p:column>
							<p:password id="txtSenha" style="width:25%;margin-left:55px"
								value="#{gestorBean.gestorSelecionado.senha}" required="true"
								requiredMessage=" *" />
								<h:message for="txtSenha" errorClass="errorMessage"
										style="font-weight: bold;font-size:18px;color:red" />
						</p:column>
					</p:row>
					<p />
				</h:panelGrid>
			</p:fieldset>
		</h:form>

	</ui:define>
</ui:composition>

</html>